<?php

namespace App\Listeners;

use App\Services\UserService;

class RecordUserReadLogOffline
{
    protected $userService;

    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct(UserService $userService)
    {
        $this->userService = $userService;
    }

    /**
     * Handle the event.
     *
     * @param  object  $event
     * @return void
     */
    public function handle($event)
    {
        $user = $event->user;
        $chapter = $event->chapter;

        $this->userService->recordUserReadLogOffline($user->id, $chapter->novel_id, $chapter->id, $chapter->order_num);
    }
}
